from flask import Blueprint,request,url_for,render_template,session,redirect

admin_blue=Blueprint('admin_blue',__name__,url_prefix='/admin')

from . import views

# @admin_blue.before_request
# def before_request():
#     '''
#     验证管理员权限
#     :return:
#     '''
#     # if not request.url.endswith(url_for('admin_blue.admin_login')):
#     # if not request.url.endswith('/admin/login'):
#     user_id=session.get('user_id')
#     is_admin=session.get('is_admin',False)
#     if not user_id or not is_admin :
#         return redirect('/')
#     pass

@admin_blue.before_request
def before_request():
    is_admin=session.get('is_admin',False)
    if not is_admin and not request.url.endswith(url_for('admin_blue.admin_login')):
        return redirect('/')

    pass
